#LD := ld -m elf_x86_64
USE_DEBUG :=
GCC := gcc
#CCFLAG := -mcpu=i386 -I../include -nostdinc -Wall -fomit-frame-pointer -c -m32
CCFLAG := -I../../include -nostdinc -ffreestanding -Wall -fomit-frame-pointer -fno-pic -fno-stack-protector -c -m32 $(USE_DEBUG)
#LDFLAG := -Ttext 0x0 -s --oformat binary -m elf_i386
#LDFLAG := -s --oformat binary -m elf_i386
LDFLAG := -r -m elf_i386
OBJS := mystdio.o mystdioas.o

mystdio: $(OBJS)
	#$(LD) $(LDFLAG) -e startup_32 -o $@ $^
	$(LD) $(LDFLAG) -o $@ $^

mystdioas.o : mystdioas.S
	$(GCC) -m32 -traditional -c -o $@ $<

mystdio.o : mystdio.c
	$(GCC) $(CCFLAG) -o $@ $<
clean :
	rm -f *.o mystdio
